<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

//常量
define('DS', DIRECTORY_SEPARATOR);


// 应用公共文件

/**
 * 上传文件
 * @Author   Yichen
 * @DateTime 2020-05-01T14:06:16+0800
 * @param    [type]                   $name [description]
 * @param    [type]                   $path [description]
 * @param    [type]                   $size [description]
 * @param    [type]                   $type [description]
 * @return   [type]                         [description]
 */
function uploadFile($name, $path, $size, $type)
{
	$file = request()->file($name);
	$info = $file->validate(['size' => $size, 'ext' => $type])->move($path);
	if (!$info) {
		return [0, $file->getError()];
	}
	$fileName = DS . $path . DS . $info->getSaveName();
	return [1, $fileName];
}